.\" Copyright (c) 2007-2020 Julien Nadeau Carriere <vedge@csoft.net>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
.\" (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd November 29, 2007
.Dt AG_PROGRESS_BAR 3
.Os
.ds vT Agar API Reference
.ds oS Agar 1.3
.Sh NAME
.Nm AG_ProgressBar
.Nd agar progress bar widget
.Sh SYNOPSIS
.Bd -literal
#include <agar/core.h>
#include <agar/gui.h>
.Ed
.Sh DESCRIPTION
.\" IMAGE(http://libagar.org/widgets/AG_ProgressBar.png, "An AG_ProgressBar widget")
The
.Nm
widget binds to minimum, maximum and value integers and displays a progress
bar representing the value.
.Sh INHERITANCE HIERARCHY
.Xr AG_Object 3 ->
.Xr AG_Widget 3 ->
.Nm .
.Sh INITIALIZATION
.nr nS 1
.Ft "AG_ProgressBar *"
.Fn AG_ProgressBarNew "AG_Widget *parent" "enum ag_progress_bar_type type" "Uint flags"
.Pp
.Ft "AG_ProgressBar *"
.Fn AG_ProgressBarNewInt "AG_Widget *parent" "enum ag_progress_bar_type type" "Uint flags" "int *value" "int *min" "int *max"
.Pp
.Ft "AG_ProgressBar *"
.Fn AG_ProgressBarNewHoriz "AG_Widget *parent" "Uint flags"
.Pp
.Ft "AG_ProgressBar *"
.Fn AG_ProgressBarNewVert "AG_Widget *parent" "Uint flags"
.Pp
.Ft void
.Fn AG_ProgressBarSetWidth "AG_ProgressBar *pb" "int width"
.Pp
.Ft void
.Fn AG_ProgressBarSetLength "AG_ProgressBar *pb" "int length"
.Pp
.Ft int
.Fn AG_ProgressBarPercent "AG_ProgressBar *pb"
.Pp
.nr nS 0
The
.Fn AG_ProgressBarNew
function allocates, initializes, and attaches a new
.Nm
widget.
.Fa type
defines the style:
.Bd -literal
enum ag_progress_bar_type {
	AG_PROGRESS_BAR_HORIZ,
	AG_PROGRESS_BAR_VERT
};
.Ed
.Pp
Acceptable
.Fa flags
include:
.Bl -tag -width "AG_PROGRESS_BAR_SHOW_PCT "
.It AG_PROGRESS_BAR_SHOW_PCT
Display text showing the percentage.
.It AG_PROGRESS_BAR_EXCL
Advise that no external changes to the
.Va value ,
.Va min
and
.Va max
bindings are expected.
By default, the binding values are periodically checked and the progress bar
is redrawn if a change is detected.
.It AG_PROGRESS_BAR_HFILL
Expand horizontally in parent container.
.It AG_PROGRESS_BAR_VFILL
Expand vertically in parent container.
.It AG_PROGRESS_BAR_EXPAND
Shorthand for
.Dv AG_PROGRESS_BAR_HFILL | AG_PROGRESS_BAR_VFILL .
.El
.Pp
The
.Fn AG_ProgressBarNewInt
variant binds the
.Sq value ,
.Sq min
and
.Sq max
bindings on initialization.
.Pp
The
.Fn AG_ProgressBarNewHoriz
and
.Fn AG_ProgressBarNewVert
variants specify the layout on initialization.
.Pp
The
.Fn AG_ProgressBarSetWidth
function sets the width of the bar in pixels.
.Pp
.Fn AG_ProgressBarSetLength
requests a preferred length in pixels.
Alternatively,
.Dv AG_PROGRESS_BAR_HFILL
or
.Dv AG_PROGRESS_BAR_VFILL
may be used.
.Pp
The
.Fn AG_ProgressBarPercent
returns the percentage for the currently bound value and range.
.Sh BINDINGS
The
.Nm
widget provides the following bindings:
.Pp
.Bl -tag -compact -width "int *value"
.It Va int *value
Current value
.It Va int *min
Minimum value
.It Va int *max
Maximum value
.El
.Sh EVENTS
The
.Nm
widget does not generate any event.
.Sh SEE ALSO
.Xr AG_Intro 3 ,
.Xr AG_Numerical 3 ,
.Xr AG_Scrollbar 3 ,
.Xr AG_Widget 3 ,
.Xr AG_Window 3
.Sh HISTORY
The
.Nm
widget first appeared in Agar 1.3.
